package com.example;

import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl implements OrderService {
    
    @Override
    public void add(String pname, int number) {
        System.out.println("添加商品: " + pname + ", 数量: " + number);
        // 模拟业务逻辑
        try {
            Thread.sleep(100); // 模拟处理时间
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    
    @Override
    public void delete(String pname) {
        System.out.println("删除商品: " + pname);
        // 模拟业务逻辑
        try {
            Thread.sleep(50); // 模拟处理时间
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    
    @Override
    public int find(String pname) {
        System.out.println("查询商品: " + pname);
        // 模拟业务逻辑
        try {
            Thread.sleep(30); // 模拟处理时间
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // 返回模拟数据
        return (int)(Math.random() * 10) + 1;
    }
}